// this assumes niftycube.js has already been loaded

window.onload = function() { 
    Nifty( '#title_content', 'big' );
    Nifty( '#legi_nav',      'big' );
    Nifty( '#exec_nav',      'big' );
    Nifty( '#judi_nav',      'big' );
    Nifty( '#taxa_content',  'big' );
    Nifty( '#taxa_listings', 'big' );
    Nifty( '#taxa_subs',     'big' );
    Nifty( '#column_one',    'big' );
    Nifty( '#column_two',    'big' );

    // add magic dividers to nav lists
    var lists = document.getElementsByTagName( 'ul' );
    for( i = 0; i < lists.length; i++ ) { 
        if( lists[i].className == 'nav_list' ) { 
            var items = lists[i].childNodes;
            var first = 1;
            for( j = 0; j < items.length; j++ ) {
                if ( items[j].tagName == 'LI' ) {
                    if ( first ) { 
                        first = 0;
                    } else { 
                        items[j].innerHTML = ' | ' + items[j].innerHTML;
                    }
                }
            }
        }
    }

    // handle footnotes
    var spans = document.getElementsByTagName( 'span' );
    var fnum = 0;
    var notes = new Array();
    for( i = 0; i < spans.length; i++ ) { 
        if ( spans[i].className == 'footnote' ) { 
            fnum++;
            notes.push( spans[i].innerHTML );
            spans[i].innerHTML = '<sup class="footnote_num"><a href="#notes"'
                + ' onClick="footnote_click(' + fnum + ')">[' + fnum + ']</a></sup>';
            spans[i].style.display = 'inline';
        }
    }

    var nlist = document.getElementById( 'notes_list' );
    if ( notes.length ) { 
        for ( i = 0; i < notes.length; i++ ) { 
            var newli = document.createElement( 'li' );
            newli.className = 'footnote_item';
            newli.innerHTML = '<a name="footnote-' + ( i+1 ) + '">' + notes[i] + '</a>';
            nlist.appendChild( newli );
        }
    }
};

function footnote_click( fnum ) { 
    var nlist = document.getElementById( 'notes_list' );
    var nitems = nlist.childNodes;
    var notes = new Array();
    for ( i = 0; i < nitems.length; i++ ) { 
        if ( nitems[i].tagName == 'LI' ) { 
            nitems[i].className = 'footnote_item';
            notes.push( nitems[i] );
        }
    }

    notes[ fnum - 1 ].className = 'footnote_item_selected';
}
            